package com.ysd.twocrm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ysd.twocrm.entity.Roles;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RolesMapper extends BaseMapper<Roles> {

    //查询当前用户的全部角色信息
    @Select(value = "select * from roles where roleid in(select roleId from userroles where userId in(select userId from users where userid=#{roleid}))")
       List<Roles> getAllRolesNameById(Integer roleid);
    //根据用户名来查询当前用户的角色
    @Select(value = "select * from roles where roleid in(select roleid from userroles where userId in(select userId from users where username=#{userName}))")
    List<Roles> getAllIfRolesByUserName(String userName);
    //根据用户id来查询当前用户的角色
    @Select(value = "select * from roles where roleid in(select roleid from userroles where userid=#{userId})")
    List<Roles> getAllIfRolesByUserId(Integer userId);

}
